import user from "../../../class/Utils/User"
import http from "../../../class/Utils/Http"
import tips from "../../../class/Utils/Tips"
Page({
    data: {
        nodata: false
    },
    onLoad: function (get) {
        var that = this
        var user = wx.getStorageSync('user');
        http.req("/Api/quan_list", {uid: user.userid}, function (res) {
            console.log(res)
            that.setData({
                list: res.list
            })
            if (res.count == 0) {
                that.setData({
                    nodata: true
                })
            }
        })


    },
    /*
     退圈
     */
    tuiquan: function (e) {
        var that = this
        var index = e.currentTarget.dataset.index
        var id = e.currentTarget.dataset.id
        var name = e.currentTarget.dataset.name
        var list = that.data.list
        tips.modal("是否退出 '" + name + "'", true, 'function', false, function () {
            var data = {
                uid: wx.getStorageSync("user").userid,
                qid: id
            }
            console.log(data)
            http.req("/Api/tuiquan", data, function (res) {
                if (res.code == '205') {
                    tips.ok(res.msg_val)
                    list.splice(index, 1);
                    if (list.length == 0) {
                        that.setData({
                            nodata: true
                        })
                    }
                    that.setData({
                        list
                    })
                } else {
                    tips.error(res.msg_val)
                }
            })

        })


    },
    /*
     跳转
     */
    goto: function (e) {
        var url = e.currentTarget.dataset.url
        var title = e.currentTarget.dataset.title
        tips.goto("/pages/shengyiquan/quan/shangji-list/shangji-list?name=" + url + "&title=" + title)

    }


})